package static_package;
/*
 * static variable can be access from static & non-static methods both,
 * while from a static method ONLY static variable & static method can
 * be accessed.
 */
class X
{
	static int count = 0;
	int var = 12;
	public X()
	{
		count = count + 1;
	}
	public static void printIt()
	{
		count ++;
		//var ++;
	}
	public int getVar()
	{
		return var+count;
	}
	
}
public class AccessStaticMethodAndVariable 
{
	public static void main(String[] args) 
	{
		X x = new X();
		X y = new X();
		// accessing static variable using Class name
		System.out.println(X.count);
		
		// accessing static variable using reference variable
		System.out.println(x.count);
		System.out.println(y.count);
		
		System.out.println(x.getVar());
	}

}
